class CompositesController < ApplicationController
  include CompositesHelper
  def index
    puts "<<<<<<< " + __method__.to_s
    puts params
    puts session
    puts ">>>>>>> " + __method__.to_s

    group_path
    group_mask

    @composites_group = composites_group
    
    Svn.new(@composites_group.path).svn_init if params[:commit] == "Update"

    @composites = @composites_group.all
    
    
    respond_to do |format|
      format.html  { }
      format.json  { render :json => @composites }
      format.xml  { render :xml => @composites }
    end
  end
  
    # GET /composite/1
  # GET /composite/1.json
  def show
    
    @composite_soa = composites_group.composite params[:id]

    @composite=Composite.collect_composite @composite_soa
    
    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @composite }
      format.xml { render xml: @composite_soa.to_xml }
    end
  end

  # PUT /composite/1
  # PUT /composite/1.json
  def update
    
    @composite = Composite.where(name: params[:composite][:name], path: params[:composite][:path]).first

    respond_to do |format|
      if @composite.update_attributes(params[:composite])
	format.html { redirect_to composite_path(params[:id]), notice: 'Composite was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "show" }
        format.json { render json: @composite.errors, status: :unprocessable_entity }
      end
    end
  end

end
